package com.javasm.mb_store_api_final.config.adminLogin.login.service.Impl;


import com.javasm.mb_store_api_final.config.adminLogin.login.entity.LoginUser;
import com.javasm.mb_store_api_final.sys_control.usercontrol.sys_user.entity.SysUser;
import com.javasm.mb_store_api_final.sys_control.usercontrol.sys_user.service.SysUserService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @className: PhoneLoginServiceImpl
 * @description
 * @author: gfs
 * @date: 2024/7/25 10:57
 * @version: 0.1
 * @since : jdk11
 */
@Service("phoneLoginService1")
public class PhoneLoginServiceImpl implements UserDetailsService {

    @Resource
    SysUserService adminUserService;

    @Override
    public UserDetails loadUserByUsername(String phone) throws UsernameNotFoundException {
        SysUser adminUser = adminUserService.getByPhone(phone);
        if (adminUser != null) {
            return new LoginUser(adminUser);
        }
        System.out.println("11111");
        return null;
    }
}
